package com.qingyun.system.model.form;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.qingyun.system.model.validator.UpdateGroup;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.web.multipart.MultipartFile;
import java.io.Serializable;

@Getter
@Setter
@NoArgsConstructor
@Schema(description = "公司添加/修改表单对象")
public class CompanyForm implements Serializable {

    private static final long serialVersionUID = 1L;
    /**
     * 主键ID (自增主键)
     */
    @NotNull(message = "公司ID不能为空",groups = { UpdateGroup.class })
    @Schema(nullable = true, requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "公司ID")
    private Long id;

    /**
     * 公司名称
     */
    @NotBlank(message = "公司名称不能为空")
    @Schema(description = "公司名称")
    private String name;

    /**
     * 营业执照文件对象
     */
    @Schema(description = "营业执照")
    @NotNull(message = "营业执照不能为空")
    private MultipartFile licenseFile;

    /**
     * 法人代表人
     */
    @NotBlank(message = "法人姓名不能为空")
    @Schema(description = "法人姓名")
    private String legalName;

    /**
     * 身份证号
     */
    @NotBlank(message = "身份证号不能为空")
    @Schema(description = "身份证号")
    private String idCardNo;

    /**
     * 身份证正面文件对象
     */
    @Schema(description = "身份证正面")
    @NotNull(message = "身份证正面不能为空")
    private MultipartFile idCardFrontFile;


    /**
     * 身份证反面文件对象
     */
    @Schema(description = "身份证反面")
    @NotNull(message = "身份证反面不能为空")
    private MultipartFile idCardBackFile;

    /**
     * 手机号
     */
    @NotBlank(message = "手机号码不能为空")
    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号码格式不正确")
    @Schema(description = "手机号码")
    private String mobile;

    /**
     * 电子邮箱
     */
    @NotBlank(message = "电子邮箱不能为空")
    @Schema(description = "电子邮箱")
    @Email(message = "电子邮箱格式不正确")
    private String email;

    /**
     * 公司地址
     */
    @NotBlank(message = "公司地址不能为空")
    @Schema(description = "公司地址")
    private String address;

    /**
     * 密码
     */
    @NotBlank(message = "密码不能为空")
    @Size(min = 6, max = 20, message = "密码长度至少6位字符")
    @Schema(description = "密码")
    private String password;


    @TableField(value = "create_by", fill = FieldFill.INSERT)
    @JsonInclude(value = JsonInclude.Include.NON_NULL)
    private Long createBy;

    @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE)
    @JsonInclude(value = JsonInclude.Include.NON_NULL)
    private Long updateBy;
}
